<%--
  Created by IntelliJ IDEA.
  User: 13585
  Date: 2020/12/23
  Time: 8:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="top.jsp"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>我的消息</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/index.css" rel="stylesheet">
    <!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
    <script src="js/jquery-3.2.1.min.js"></script>
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="js/bootstrap.min.js"></script>
</head>
<body>
<div id="message" class="panel panel-default">
    <div class="panel-heading">我的消息</div>
    <div class="contain row">
        <div class="col-md-4">
            <div class="title">
                <ul>
                    <c:forEach items="${messageBeans}" var="messageBean" varStatus="vs">
                        <li>
                            <span id="notice${vs.count}" class="${messageBean.style}"></span>
                            <a class="msg" onclick=showContent(${messageBean.message.id},"${messageBean.message.content}",${vs.count})>系统消息</a>
                            <span class="time">${messageBean.sendtime}</span><span id="status${vs.count}">(${messageBean.status})</span><a href="delMessage?id=${messageBean.message.id}" class="icon glyphicon glyphicon-trash" aria-hidden="true" onclick="return confirm('你确定要删除吗,删除后将无法恢复')"></a>
                        </li>
                    </c:forEach>
                </ul>
            </div>
        </div>
        <div class="col-md-8">
            <div class="content">
                <p class="text"></p>
            </div>
        </div>
    </div>
</div>
<script>
    function showContent(id,content,count) {
        let ajax;
        if(window.XMLHttpRequest){
            ajax = new XMLHttpRequest();
        }else {
            ajax = new ActiveXObject("Microsoft.XMLHttp");
        }
        ajax.open("get","messageContent?id="+id);
        ajax.send()
        let notice = document.getElementById("notice"+count);
        let status = document.getElementById("status"+count);
        let p = document.getElementsByClassName("text")[0];

        notice.className = "read";
        status.innerHTML = "已读";
        p.innerHTML = content;
    }
</script>
</body>
</html>
